//
//  Macros.h
//  mijifen_ios
//
//  Created by 朱凯 on 2017/10/9.
//  Copyright © 2017年 itboye. All rights reserved.
//

#ifndef Macros_h
#define Macros_h

//app ID
//com.itboye.lottery   //云彩
//net.ixiaoyuan.a   //天天购彩票
//api.whshyyw.com   //汇众彩
//ru1.cn          //天天彩
//rrgc.8raw.com 测试

//////测试
//////apiURL
//#define BOYE_BASE_URL @"http://rrgc.8raw.com/api.php"
////H5页
//#define BOYE_WEB_BASE_URL @"http://rrgc.8raw.com/index.php"



//云彩
// 基础apiURL
#define BOYE_BASE_URL @"http://api.t0x9.cn/api.php"
// H5页面地址
#define BOYE_WEB_BASE_URL  @"http://api.t0x9.cn/index.php"


////天天购彩票
////apiURL
//#define BOYE_BASE_URL @"http://api.ixiaoyuan.net/api.php"
////H5页
//#define BOYE_WEB_BASE_URL @"http://api.ixiaoyuan.net/index.php"



////汇众彩
////apiURL
//#define BOYE_BASE_URL @"http://api.whshyyw.com"
////H5页
//#define BOYE_WEB_BASE_URL @"http://api.whshyyw.com/index.php"


////天天彩
////apiURL
//#define BOYE_BASE_URL @"http://api.8ru1.cn"
////H5页
//#define BOYE_WEB_BASE_URL @"http://api.8ru1.cn/index.php"


// 接口地址定义 ————————————————————————————————
// client
#define BOYE_CLIENT_ID      @"by_ios_test_client_id"
#define BOYE_CLIENT_SECRET  @"byTestSecret654321"

// 图片地址
#define BOYE_IMAGE_URL_ORIGINAL(id)     [NSString stringWithFormat:@"%@/picture/index?id=%@", BOYE_API_URL, id]
#define BOYE_IMAGE_URL(id, size)        [NSString stringWithFormat:@"%@/picture/index?id=%@&size=%@", BOYE_API_URL, id, size]
// 图片地址
#define BOYE_PICTURE_VIEW_URL(id)       [NSString stringWithFormat:@"%@/picture/index?id=%@", BOYE_BASE_URL, id]


// 系统相关宏 ————————————————————————————————————
// 打印
#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(...)
#endif

// 判断版本号
#define SYSTEM_VERSION_EQUAL_TO(v)                  ([UIDevice currentDevice].systemVersion.doubleValue == v)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([UIDevice currentDevice].systemVersion.doubleValue > v)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([UIDevice currentDevice].systemVersion.doubleValue >= v)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([UIDevice currentDevice].systemVersion.doubleValue < v)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([UIDevice currentDevice].systemVersion.doubleValue <= v)

// 系统
#define APP_SCHEME              [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]
#define APP_NAME                [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]
#define APP_SHORT_VERSION       [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
#define APP_BUNDLE_VERSION      [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
#define APP_VERSION             [NSString stringWithFormat:@"%@.%@", APP_SHORT_VERSION,APP_BUNDLE_VERSION]

// 常用宏 ————————————————————————————
#define BY_USER [ByCacheUser getUserInfo]
#define BY_APPDELEGATE ((AppDelegate *)[UIApplication sharedApplication].delegate)
#define BY_CONFIG ByNetConfig
#define KEY_SERVICE_INFO  @"service"

// 宽高
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
#define STATUS_NAV    ([[UIApplication sharedApplication] statusBarFrame].size.height + self.navigationController.navigationBar.frame.size.height)


// 颜色
#define BY_THEME_COLOR rgba(216, 29, 54, 1)
#define rgba(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define BY_TEXT_COLOR [UIColor blackColor]
#define BY_TABLE_COLOR rgba(244, 245, 246, 1)
#define FONT(size) [UIFont systemFontOfSize:size]
#define B_FONT(size) [UIFont boldSystemFontOfSize:size]
#define BY_BACKGROUND_COLOR rgba(246, 246, 246, 1)
#define BY_LINE_COLOR [UIColor colorWithHexString:@"#EDEDED"]
#define BY_Blue_COLOR rgba(3, 164, 213, 1)

#define Table_Height 120

#define Documentary_Table_Height 120

// 默认图片
#define DEFAULT_IMAGE [UIImage imageNamed:@"lanqiu"]
#define HEAD_ICOM_IMAGE [UIImage imageNamed:@"头像默认"]

#define isDebug YES

#define Device_Is_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)



// 判断是否为iPhone X 系列  这样写消除了在Xcode10上的警告。
#define IPHONE_X \
({BOOL isPhoneX = NO;\
if (@available(iOS 11.0, *)) {\
isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
}\
(isPhoneX);})

/**
 *导航栏高度
 */
#define SafeAreaTopHeight (IPHONE_X ? 88 : 64)

/**
 *tabbar高度
 */
#define SafeAreaBottomHeight (IPHONE_X ? (49 + 34) : 49



#ifdef isDebug
#define SLog(format, ...) printf("class: <%p %s:(%d) > method: %s \n%s\n", self, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String] )
#else
#define SLog(format, ...)
#endif



// ios11滑动视图适配
#define adjustsScrollViewInsets_NO(scrollView,vc)\
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
if ([UIScrollView instancesRespondToSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:")]) {\
    [scrollView performSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:") withObject:@(2)];\
} else {\
    vc.automaticallyAdjustsScrollViewInsets = NO;\
}\
_Pragma("clang diagnostic pop") \
} while (0)

#endif /* Macros_h */
